// ignore_for_file: file_names, slash_for_doc_comments, must_call_super, unnecessary_overrides, override_on_non_overriding_member, must_be_immutable, prefer_const_constructors, sized_box_for_whitespace, avoid_unnecessary_containers, avoid_print

import 'package:flutter/material.dart';
import 'package:mybaseplus/base/abstract/IFFR.dart';
import 'package:mybaseplus/base/abstract/IFFRefresh.dart';
import 'package:mybaseplus/base/abstract/IFFScaffold.dart';
import 'package:mybaseplus/base/widget/layout/FFLineContainer.dart';
import 'package:mybaseplus/base/widget/layout/FFNavi2.dart';
import 'package:mybaseplus/base/widget/layout/FFTestClick.dart';
import 'package:mybaseplus/base/widget/layout/FFTextButton.dart';
import 'package:mybaseplus/base/widget/page/FFScaffold.dart';
import 'package:mybaseplus/base/tool/extension/FFListExt.dart';
import 'package:mybaseplus/module/windows/TextToastWindow.dart';
import 'package:mybaseplus/module/windows/windowtool/FFWindowTool.dart';

class TestShowWindows extends FFScaffold {
  String? name;

  TestShowWindows({
    Key? key,
    this.name,
  }) : super(key: key);

  @override
  TestShowWindowsState createState() => TestShowWindowsState();
}

class TestShowWindowsState extends FFScaffoldState with MFFScaffold {
  /**固定写法 */
  @override
  IFFScaffold get iffScaffold => this;

  @override
  TestShowWindows get widget => super.widget as TestShowWindows;

  @override
  IFFRefresh? get iffRefresh => refresh;
  late TestShowWindowsRefresh refresh = TestShowWindowsRefresh(state: this);

  /**固定写法end */

  @override
  void ffInitState() {
    super.ffInitState();
  }

  @override
  Widget? ffNavi(BuildContext context) {
    return FFNavi2.createNavi(
      context,
      title: "弹窗",
    );
  }

  @override
  Widget? ffBody(BuildContext context) {
    List<Widget> slivers = [
      SliverToBoxAdapter(
        child: Container(
          child: FFLineContainer(
            children: [
              FFTestClick(
                  text: "吐思文本",
                  onClick: () {
                    FFWindowTool.showToastByBottom(text: "这是测试文本");
                  }),
            ],
          ),
        ),
      ),
    ];
    return CustomScrollView(slivers: slivers);
  }
}

class TestShowWindowsRefresh with MFFRefresh {
  TestShowWindowsState state;

  TestShowWindowsRefresh({required this.state});

  @override
  bool? ffCanRefreshHead() {
    return true;
  }

  @override
  ffRefresh(bool isHead) {
    ffRefreshResult(isHead, test, state);
  }

  //具体请求业务
  Future<IFFR> test(IRefreshParam? iRefreshParam) async {
    List? list;
    await Future.wait([
      //HomeApi.index_recentlyPlayed(),
    ]).then((value) {
      list = value;
    });

    IFFR? r = list?.safeValue(0);
    return r ?? R(rStatus: RStatus.result);
  }
}
